package test;

import java.io.InputStream;
import java.sql.SQLXML;
import java.util.List;

import javax.lang.model.element.ExecutableElement;

import model.address.Address;
import model.address.AddressList;
import model.database.CallStatement;
import model.database.CallStatus;
import model.xml.SerializeObject;

import org.simpleframework.xml.Serializer;
import org.simpleframework.xml.core.Persister;




public class StartPoint {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		try {
			
//			//1 Step. Create object of any class and populate it data
//			Address address = new Address();
//			address.setAddressName("Far far away");
//			address.setId(1);
//			
//			System.out.println(SerializeObject.serializeToString(address));//view xml data as text just for great justy
//			
//			//2 Step. Call store procedure
//			CallStatement callStatement = new CallStatement("AddressSave", SerializeObject.serializeToOutputStream(address));
//			SQLXML sqlxml = callStatement.execute(); // get xml data
//			callStatement.close(); //good guy close 
//			
//			//3. create object and populate it data from xml returned by database
//			CallStatus callStatus = (CallStatus)SerializeObject.deSerializeFromXml(CallStatus.class, sqlxml); 
//			
//			//4. View result and enjoi
//			System.out.println(callStatus.getStatusCode() + " | " + callStatus.getStatusMessage());
		
			Address address1 = new Address(); address1.setAddressName("Some Address 1");
			Address address2 = new Address(); address2.setAddressName("Some Address 2");
			
			AddressList addressList = new AddressList();
			addressList.getAddressList().add(address1);
			addressList.getAddressList().add(address2);
			
			List<Address> allAddresses = address1.getAllAddress();
			
			System.out.println(SerializeObject.serializeToString(addressList));
			
			
			
		}
		catch(Exception exception) {
			exception.printStackTrace();
			System.out.println();
		} 

	}

}
